package com.zl.smartmall.library.account.po;

import net.tsz.afinal.annotation.sqlite.Id;
import net.tsz.afinal.annotation.sqlite.Property;
import net.tsz.afinal.annotation.sqlite.Table;

import org.json.JSONException;
import org.json.JSONObject;

@Table(name = "tb_UserInfo")
public class UserInfo {

	@Id
	private int id;
	@Property
	private int uid;
	@Property
	private int gender;
	@Property
	private int loginType;// 账号类型 : 0 用户名注册; 1 匿名注册 ; 2 第三方登陆
	@Property
	private long expiretime;
	@Property
	private String openId;
	@Property
	private String accessToken;
	@Property
	private String token;
	@Property
	private String nickname;
	@Property
	private String face;
	@Property
	private String loginPlatform;
	
//	private int thirdPartyGender;
//	private String thirdPartyNickname;
//	private String thirdPartyFace;
//  private int rand;
//  private long datetime;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getUid() {
		return uid;
	}

	public void setUid(int uid) {
		this.uid = uid;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public int getLoginType() {
		return loginType;
	}

	public void setLoginType(int loginType) {
		this.loginType = loginType;
	}

//	public int getThirdPartyGender() {
//		return thirdPartyGender;
//	}
//
//	public void setThirdPartyGender(int thirdPartyGender) {
//		this.thirdPartyGender = thirdPartyGender;
//	}

	public long getExpiretime() {
		return expiretime;
	}

	public void setExpiretime(long expiretime) {
		this.expiretime = expiretime;
	}

//	public String getThirdPartyNickname() {
//		return thirdPartyNickname;
//	}
//
//	public void setThirdPartyNickname(String thirdPartyNickname) {
//		this.thirdPartyNickname = thirdPartyNickname;
//	}
//
//	public String getThirdPartyFace() {
//		return thirdPartyFace;
//	}
//
//	public void setThirdPartyFace(String thirdPartyFace) {
//		this.thirdPartyFace = thirdPartyFace;
//	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getFace() {
		return face;
	}

	public void setFace(String face) {
		this.face = face;
	}

	public String getLoginPlatform() {
		return loginPlatform;
	}

	public void setLoginPlatform(String loginPlatform) {
		this.loginPlatform = loginPlatform;
	}

	public static UserInfo parse(JSONObject jsonObject) throws JSONException {		
		if(jsonObject != null && jsonObject.length() > 0) {
			UserInfo userInfo = new UserInfo();
			userInfo.accessToken = jsonObject.getString("qq_accesstoken");
			userInfo.expiretime = jsonObject.getLong("expiretime");
			userInfo.face = jsonObject.getString("face");
			userInfo.gender = jsonObject.getInt("gender");
			userInfo.loginType = jsonObject.getInt("loginType");
			userInfo.nickname = jsonObject.getString("nickname");
			userInfo.openId = jsonObject.getString("qq_openid");
//			userInfo.thirdPartyFace = jsonObject.getString("qq_face");
//			userInfo.thirdPartyGender = jsonObject.getInt("qq_gender");
//			userInfo.thirdPartyNickname = jsonObject.getString("qq_nickname");
			userInfo.token = jsonObject.getString("token");
			userInfo.uid = jsonObject.getInt("uid");
			return userInfo;
		}
		
		return null;
	}
	
}
